<!doctype html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport"
			content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.css" rel="stylesheet" />
		<script src="js/mui.js"></script>
		<script src="./utils/myRequest.js"></script>
		<script type="text/javascript">
			mui.init();
			mui.plusReady(function() {
				var friendPlayId = plus.webview.currentWebview().friendPlayId;
				var status = plus.webview.currentWebview().status;
				console.log(friendPlayId + "=" + status);
				// plus.nativeUI.toast(friendPlayId + "=" + status);

				request.ajax({
					url: "/websocket/t-friend-apply/getFriendById",
					data: {
						id: friendPlayId
					},
					type: "post",
					success: function(resp) {
						console.log(typeof resp);
						if (resp.code == 20000) {
							var friendApply = resp.data.friendApply;
							document.getElementById("username").innerText = friendApply.tuser.username;
							document.getElementById("nickname").innerText = friendApply.tuser.nickname;
							document.getElementById("minImg").src = friendApply.tuser.minHeand;
							document.getElementById("msg").innerText = friendApply.msg;
						}
					}
				});

				//验证
				document.getElementById("addFriend").addEventListener("tap", function() {
					var param = new Object();
					param.friendPlayId = friendPlayId;
					param.status = status;
					param.remark = document.getElementById("remark").value;
					request.ajax({
						url: "/websocket/t-friend-apply/addFriend",
						data: param,
						type: "post",
						success: function(resp) {
							console.log(typeof resp);
							if (resp.code == 20000) {
								plus.nativeUI.toast(resp.message);
								//刷新页面
								// location.reload(true);
								// mui.back();
								plus.webview.open("./index.html", "index.html");
								//关闭当前页
								plus.webview.currentWebview().close();
							} else {
								plus.nativeUI.toast(resp.message);
							}
						}
					})
				});

			});
		</script>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">好友验证</h1>
		</header>

		<div style="margin-top: 50px;">
			<ul class="mui-table-view" id="ul" style="margin-top: 50px;margin-bottom: 10px;">
				<li class="mui-table-view-cell mui-media">
					<a href="javascript:;">
						<img class="mui-media-object mui-pull-left" style="border-radius: 50%;" id="minImg"
							src="img/tou.jpg">
						<div class="mui-media-body">
							<p id="username" class="mui-ellipsis"></p>
							<p id="nickname" class="mui-ellipsis"></p>
						</div>
					</a>
				</li>
			</ul>
			<p style="margin-left: 10px;">验证信息</p>
			<textarea disabled="disabled" id="msg" style="color: #999999;">你好y</textarea>
			<p style="margin-left: 10px;">备注</p>
			<input id="remark" type="text" placeholder="请输入备注" style="margin-bottom: 50px;" />
			<ul class="mui-table-view" style="text-align: center;color: white;background-color: #2AC845;">
				<li class="mui-table-view-cell mui-media" id="addFriend">
					<a href="javascript:;">
						完成
					</a>
				</li>
			</ul>
		</div>
	</body>

</html>
